package app.server.project.core.util;

import app.server.project.core.constants.Def;

public class MathUtil {

    public static String getNumFormat(long val, long rate) {
        String str = String.valueOf(rate);
        var formatStr = "%." + (str.length() - 1) + "f";
        double ret = (double) val / rate;
        return String.format(formatStr, ret);
    }

    public static long canAddNum(long current, long target) {
        if (Long.MAX_VALUE == current) return Def.Zero;
        var diff = Long.MAX_VALUE - current;
        if (target >= diff) {
            return diff;
        } else {
            return target;
        }
    }
}
